package com.aaa.service.impl;

import com.aaa.dao.MenuDao;
import com.aaa.entity.Menu;
import com.aaa.service.MenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 菜单权限表(Menu)表服务实现类
 *
 * @author
 * @since 2022-06-27 11:26:10
 */
@Service("menuService")
public class MenuServiceImpl implements MenuService {
    @Resource
    private MenuDao menuDao;

    @Override
    public Map<String, List<Menu>> findMenuByUsername(String username) {
        List<Menu> menuList = menuDao.findMenuByUsername(username);
        //获取所有的一级菜单
        List<Menu> menuListlevel1=new ArrayList<>();
        //获取所有的二级菜单
        List<Menu> menuListlevel2=new ArrayList<>();
        for (Menu menu : menuList) {
            if(menu.getMenuType().equals("M")){
                menuListlevel1.add(menu);
            }
            if(menu.getMenuType().equals("C")){
                menuListlevel2.add(menu);
            }
        }
        Map<String, List<Menu>> map= new HashMap();
        map.put("menuListlevel1",menuListlevel1);
        map.put("menuListlevel2",menuListlevel2);
        return map;
    }


   /* @Override
    public List<Menu> findMenuByUsername(String username) {
        return menuDao.findMenuByUsername(username);
    }*/

}
